package com.prize.controller;

import com.prize.dtos.ResponseResult;
import com.prize.members.apis.LevelControllerApi;
import com.prize.pojo.member.Level;
import com.prize.service.LevelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @descriptions: 等级管理
 * @author: yunqiang
 * @date: 2022/5/28 19:00
 */
@Api(tags = {"等级管理：等级管理"})
@RestController
@RequestMapping("/api/v1/level")
public class LevelController implements LevelControllerApi {

    @Autowired
    private LevelService levelService;

    @ApiOperation(value = "等级列表")
    @PostMapping("/getLevels")
    public ResponseResult getLevels(String levelName, int pageSize, int pageNow) {
        return levelService.getLevels(levelName,pageSize,pageNow);
    }

    @ApiOperation(value = "全量等级")
    @GetMapping("/allLevel")
    public ResponseResult allLevel() {
        return levelService.allLevel();
    }

    @ApiOperation(value = "新增等级")
    @PostMapping("/addLevel")
    public ResponseResult addLevel(@RequestBody Level level) {
        return levelService.addLevel(level);
    }

    @ApiOperation(value = "修改等级")
    @PostMapping("/updateLevel")
    public ResponseResult updateLevel(@RequestBody Level level) {
        return levelService.updateLevel(level);
    }

    @ApiOperation(value = "删除等级")
    @GetMapping("/delLevel/{id}")
    public ResponseResult delLevel(@PathVariable Integer id) {
        return levelService.delLevel(id);
    }
}
